package membermanage.model.service;

import java.sql.SQLException;
import java.util.ArrayList;
import membermanage.dto.ZipcodeDTO;
import membermanage.model.dao.ZipcodeDAO;

public class ZipcodeService {
	private static ZipcodeService instance;
	private ZipcodeDAO zdao;
	private ZipcodeService(){}
	public static ZipcodeService getInstance(){
		if(instance == null){
			instance = new ZipcodeService();
		}
		return instance;
	}
	public void setZipcodeDAO(ZipcodeDAO zdao){
		this.zdao = zdao;
	}
	
	public ArrayList<ZipcodeDTO> addCheck(String address) throws SQLException{
		ArrayList<ZipcodeDTO> list = zdao.addCheck(address);
		for(ZipcodeDTO zdto : list){
			zdto.setZipcode(zdto.getZipcode().substring(0, 3) + " - " + zdto.getZipcode().substring(3, 6));
		}
		return list; 
	}
}
